

void processSerial() {
 
 // read the incoming byte:
int incomingByte = Serial.read();

if ((incomingByte >= '0') && (incomingByte <= '9')) {
  predefinedMode=int(incomingByte)-48;
  modeChange(predefinedMode);
} else // this means that it is a COMMAND, not a mode change 
switch(incomingByte) {
   
  // change radius:
  case '+':
   for(int i=0; i<NBSPOT; i++){
    spotArray[i].setAperSaccade(spotArray[i].Aper_DA+5);
    }
    break;
    case '-':
   for(int i=0; i<NBSPOT; i++){
    spotArray[i].setAperSaccade(spotArray[i].Aper_DA-5);
    }
    break;
  
  case 'r': // decoration: trace the recentering vector while tracking, following, etc
    for(int i=0; i<NBSPOT; i++){
    spotArray[i]. traceNormalVector=true;
    }
   break;
   case 'R': 
    for(int i=0; i<NBSPOT; i++){
    spotArray[i]. traceNormalVector=false;
    }
   break;
  
   case 'd': // decoration: show distance as a text near the tracking spot
    for(int i=0; i<NBSPOT; i++){
    spotArray[i].displayDistance=true;
    }
   break;
   case 'D': 
    for(int i=0; i<NBSPOT; i++){
    spotArray[i].displayDistance=false;
    }
   break;
   
    case 'a': // decoration 3: show angle as a text near the tracking spot
    for(int i=0; i<NBSPOT; i++){
    spotArray[i].displayAngle=true;
    }
   break;
   case 'A': 
    for(int i=0; i<NBSPOT; i++){
    spotArray[i].displayAngle=false;
    }
   break;
   
   case 'm':
    for(int i=0; i<NBSPOT; i++){
    spotArray[i].displayMonocycle=true;
    }
   break;
     case 'M':
    for(int i=0; i<NBSPOT; i++){
    spotArray[i].displayMonocycle=false;
    }
   break;
   
   
   case 'g': // GREEN LASER ON/OFF:
     for(int i=0; i<NBSPOT; i++){
    spotArray[i].GreenLaserPower=HIGH;
    }
    break;
   case 'G': // GREEN LASER ON/OFF:
     for(int i=0; i<NBSPOT; i++){
    spotArray[i].GreenLaserPower=LOW;
    }
    break;
  
   case 'n': 
    for(int i=0; i<NBSPOT; i++){
    spotArray[i].RadiusCorrectionMode= RADIUS_FIXED;
    }
   break;
    case 'N': 
    for(int i=0; i<NBSPOT; i++){
    spotArray[i].RadiusCorrectionMode= RADIUS_ADJUST; 
    }
   break;
   
 default: 
  break; 
}
}


